package com.common.controller;

import com.common.model.Result;
import com.mrobuy.jdvc.entity.JDAccount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 店铺管理
 */
@RestController
public class ShopController {

	private static Logger LOG = LoggerFactory.getLogger(ShopController.class);

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@RequestMapping("/common/shops")
	public Result shops(@RequestParam int page, @RequestParam int limit, @RequestParam(value = "searchParams", defaultValue = "{}") String searchParams) {


		List<JDAccount> menuList =  jdbcTemplate.query("select * from JD_ACCOUNT", new BeanPropertyRowMapper<>(JDAccount.class));

		Result<JDAccount> result = new Result();
		result.setCode(0);
		result.setCount(menuList.size());
		result.setData(menuList);

		return  result;
	}

}
